//
//  JBWSDKInstance.m
//  HYSDK
//
//  Created by 崔志伟 on 2018/7/26.
//  Copyright © 2018年 崔志伟. All rights reserved.
//

#import "JBWSDKInstance.h"
#import "JBWLoginViewController.h"
#import "JBWCommonParameterManager.h"
#import "JBWRechargeCenterViewController.h"
#import "JBWNetWorkManager.h"

@interface JBWSDKInstance ()

@end

@implementation JBWSDKInstance

+(instancetype )sharedInstance{
    
    static JBWSDKInstance * sdkInstance = nil;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sdkInstance = [[JBWSDKInstance alloc]init];
    });
    return sdkInstance;
}

- (void)jbwSDKInitWithAppID:(NSString *)appID appKey:(NSString *)appkey appVersion:(NSString *)appVersion{
    [[JBWCommonParameterManager sharedInstance] setSDKVersion:appVersion];
    [[JBWCommonParameterManager sharedInstance] setAPPkey:appkey];
    [[JBWCommonParameterManager sharedInstance] setAppID:appID];
    [JBWNetWorkManager  getUrl:[NSString stringWithFormat:@"%@%@",JBW_BASE_URL,JBW_GET_IPURL]  parameters:nil startRequest:^{} finishRequest:^(NSData *resultData) {
        NSString * ipUrlStr  =[[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding];
        NSLog(@"---ipUrlStr%@",ipUrlStr);
        [JBWNetWorkManager getUrl:ipUrlStr  parameters:nil startRequest:^{} finishRequest:^(NSData *resultData) {
           
        } errorRequest:^(NSError *error) {
            
        }];
    } errorRequest:^(NSError *error) {
        
    }];
    
    [JBWNetWorkManager getUrl:[NSString stringWithFormat:@"%@%@",JBW_BASE_URL,JBW_SDK_INIT] parameters:nil startRequest:^{} finishRequest:^(NSData *resultData) {
        NSString * dddStr  =[[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding];
        NSLog(@"---dddStr%@",dddStr);
    } errorRequest:^(NSError *error) {
        
    }];
    
    
    
    
}
- (void)jbwLogin{
    
    [JBW_KEY_WINDOW.rootViewController presentViewController:[JBWLoginViewController new] animated:NO completion:nil];
    
//      [JBW_KEY_WINDOW.rootViewController presentViewController:[JBWRechargeCenterViewController new] animated:NO completion:nil];
    
}

- (void)jbwLogout{
    
    
}
- (void)jbwSyncDataWithActionType:(JBWActionType)actionType zoneId:(NSString *)zoneId zoneName:(NSString *)zoneName roleId:(NSString *)roleId roleName:(NSString *)roleName roleLevel:(NSString *)roleLevel gameCoin:(NSNumber *)gameCoin callback:(JBWCallback)callback{
    
    
    
}
- (void)PayOrderWithInfo:(JBWPayModel *) info{
    
    
    
}
- (BOOL)jbwHandleOpenURL:(NSURL *)url{
    
    return YES;
    
}
- (BOOL)jbwOpenURL:(NSURL *)url options:(NSDictionary*)options{
    
    return YES;

}

- (void)jbwApplicationWillEnterForeground:(UIApplication *)application{
    
    
}

- (void)jbwApplicationWillTerminate:(UIApplication *)application{
    
    

}

- (UIInterfaceOrientationMask) jbwSupportedInterfaceOrientationsForWindow:(UIWindow *)window{
    return UIInterfaceOrientationMaskLandscape;
}

@end
